<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions">

    <h:head>
        <title>Goalkeeper E-Shop</title>
        <h:outputStylesheet library="css" name="style.css" />
    </h:head>
    <h:body>

        <ui:composition template="template.xhtml">
            <ui:define name="content">
                <br/>
                <h:outputText styleClass="h1" value="#{msg.updateProduct}" />
                <br/>
                <br/>
                <h:messages styleClass="h2" />
                <br/>
                <h:form>
                    <rich:dataTable id="data" value="#{shopData.productList}" var="product">
                        <f:facet name="noData">#{msg.overviewNoData}</f:facet>
                        <rich:column filterValue="#{productFilter.categoryFilter}" filterExpression="#{fn:containsIgnoreCase(product.category, productFilter.categoryFilter)}">
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="#{msg.overviewCategory}" />
                                    <h:selectOneMenu value="#{productFilter.categoryFilter}">
                                        <f:selectItems value="#{shopData.filterCategoryList}" />
                                        <a4j:ajax render="data" execute="@this" event="change" />
                                    </h:selectOneMenu>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{product.category}" />
                        </rich:column>
                        <rich:column filterValue="#{productFilter.labelFilter}" filterExpression="#{fn:containsIgnoreCase(product.label, productFilter.labelFilter)}">
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="#{msg.overviewLabel}" />
                                    <h:selectOneMenu value="#{productFilter.labelFilter}">
                                        <f:selectItems value="#{shopData.filterLabelList}" />
                                        <a4j:ajax render="data" execute="@this" event="change" />
                                    </h:selectOneMenu>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{product.label}" />
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText value="#{msg.overviewName}" />
                            </f:facet>
                            <h:outputText value="#{product.name}" />
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText value="#{msg.overviewSize}" />
                            </f:facet>
                            <h:outputText value="#{product.size}" />
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText value="#{msg.overviewPrice}" />
                            </f:facet>
                            <h:outputText value="#{product.price}">
                                <f:convertNumber type="currency" currencySymbol="€" />
                            </h:outputText>
                        </rich:column>
                        <rich:column style="text-align: center">
                            <f:facet name="header">
                                <h:outputText value="#{msg.updateButton}" />
                            </f:facet>
                            <h:outputLink value="productUpdateForm.xhtml">
                                <h:graphicImage library="img" name="update.jpg" />
                                <f:param name="index" value="#{product.id}" />
                            </h:outputLink>
                        </rich:column>
                    </rich:dataTable>
                </h:form>
                <br/>
                <br/>
            </ui:define>
        </ui:composition>

    </h:body>
</html>
